package org.example.demo;

import java.util.Scanner;

/**
 * @Author chaigq
 * @Date 2021/3/6 下午2:20
 * @Version 1.0
 */
public class testDemo {


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

    }
    public static int sumString(String s){
        if (s.length() <= 0){
            return 0;
        }
        StringBuilder stringBuilder = new StringBuilder();
        String[] strings = s.split("");
        for (int i = 0; i < strings.length; i++) {
            if (strings[i].equals("-") || strings[i].equals("+") || strings[i].equals("0") || strings[i].equals("1") || strings[i].equals("2")
                    || strings[i].equals("3") || strings[i].equals("4") || strings[i].equals("5") || strings[i].equals("6") || strings[i].equals("7")
                    || strings[i].equals("8") || strings[i].equals("9")){
                stringBuilder.append(strings[i]);
            }
        }
        String s1 = stringBuilder.toString();
        int sum = 0;
        String[] strings1 = s1.split("-");
        for (int i = 0; i < strings1.length; i++) {
            sum = sumString2(strings1[i]) - sum;
        }
        return sum;
    }
    public static int sumString2(String s1){
        int count = 0;
        String[] strings = s1.split("");
        for (int i = 0; i < strings.length; i++) {
            if (!strings[i].equals("+")){
                count += Integer.valueOf(strings[i]);
            }
        }
        return count;
    }
}
